package com.snts.synchronization.core;

import java.util.Date;

public class BaseTable {

	protected String catalog;
	protected String schema = "public";
	protected String name;
	protected boolean quoteIdentifier = false;
	
	public BaseTable(String schema, String name) {
		this(schema, name, false);
	}
	
	public BaseTable(String schema, String name, boolean quoteIdentifier) {
		super();
		if(schema != null){
			this.schema = schema;
		}
		this.name = name;
		this.quoteIdentifier = quoteIdentifier;
	}
	

	public BaseTable() {
		super();
		// TODO Auto-generated constructor stub
	}

	public String getCatalog() {
		return catalog;
	}

	public void setCatalog(String catalog) {
		this.catalog = catalog;
	}

	public String getSchema() {
		return schema;
	}

	public void setSchema(String schema) {
		this.schema = schema;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public String getQualifiedName(){
		String name = this.name;
		if(isQuoteIdentifier()){
			name = '"' + name + '"';
		}
		return schema + "." + name;
	}
	
	protected boolean isQuoteIdentifier(){
		return quoteIdentifier;
	}

	@Override
	public boolean equals(Object obj) {
		if(!(obj instanceof BaseTable)){
			return false;
		}
		BaseTable baseTable = (BaseTable) obj;
		return getSchema().equals(baseTable.getSchema()) && getName().equals(baseTable.getName());
	}

	@Override
	public int hashCode() {
		return getName() != null ? getName().hashCode() : 0;
	}

	@Override
	public String toString() {
		return "BaseTable [schema=" + schema + ", name=" + name + "]";
	}
	
	

}
